package cn.bugDance.test.domain.strategy;


import cn.bugDance.domain.activity.service.armory.IRaffleActivityArmory;
import cn.bugDance.domain.strategy.model.entity.RaffleAwardEntity;
import cn.bugDance.domain.strategy.model.entity.RaffleFactorEntity;
import cn.bugDance.domain.strategy.service.IRaffleStrategyService;
import cn.bugDance.domain.strategy.service.algorithm.IAlgorithm;
import cn.bugDance.domain.strategy.service.armory.IRaffleStrategyArmory;
import cn.bugDance.domain.strategy.service.dispatch.IRaffleStrategyDispatch;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.CountDownLatch;

@SpringBootTest
@RunWith(SpringRunner.class)
@Slf4j
public class RaffleStrategyServiceTest {

    @Resource
    private IRaffleStrategyService raffleStrategyService;
    @Resource
    private IRaffleStrategyArmory raffleStrategyArmory;
    @Resource
    private IRaffleStrategyDispatch raffleStrategyDispatch;
    @Resource
    private IRaffleActivityArmory activityArmory;

    private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");



    @Test
    public void test(){
        Long strategyId = activityArmory.assembleRaffleActivity(100301L);
        Date endTime = activityArmory.queryActivityEndTime(100301L);
        raffleStrategyArmory.assembleRaffleStrategy(strategyId, endTime);
    }

    @Test
    public void test2(){
        RaffleFactorEntity raffleFactorEntity = new RaffleFactorEntity();
        raffleFactorEntity.setUserId("yangxiaocan");
        raffleFactorEntity.setStrategyId(100001L);
        Date endTime = activityArmory.queryActivityEndTime(100301L);
        raffleFactorEntity.setEndDateTime(endTime);
        raffleFactorEntity.setDay(dateFormat.format(new Date()));
        raffleFactorEntity.setActivityId(100301L);

        RaffleAwardEntity raffleAwardEntity = raffleStrategyService.performRaffle(raffleFactorEntity);
        log.info("结果为: {}", raffleAwardEntity);
    }


}
